﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DTO;

namespace DAO
{
    public class ThamSoDAO
    {
        public static bool Sua(ThamSo aCT)
        {
            try
            {
                QLSTLinqDataContext rv = new QLSTLinqDataContext();
                var query =
    (from ord in rv.ThamSos
     where ord.Id == 1
     select ord).First();

                query.TongGiaTriQD = aCT.TongGiaTriQD;
                query.SoDiemCongThem= aCT.SoDiemCongThem;
                query.SoDiemDeGiamGia = aCT.SoDiemDeGiamGia;
                query.PhanTramGiam = aCT.PhanTramGiam;

                rv.SubmitChanges();


                return true;
            }
            catch
            {
                return false;
            }
        }

        public static ThamSo hienThongTin()
        {
            try
            {
                ThamSo temp = new ThamSo();
                QLSTLinqDataContext rv = new QLSTLinqDataContext();
                var query = from c in rv.ThamSos
                            where c.Id == 1
                            select c;

                temp = query.First();

                return temp;


            }
            catch
            {
                return null;
            }
        }
    }
}
